﻿@model BrnMall.Web.MallAdmin.Models.AdvertModel

@section header{
    <title>编辑广告</title>
    <link type="text/css" rel="stylesheet" href="/admin_mall/content/css/site.css"/>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.js"></script>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="/admin_mall/scripts/jquery.validate.unobtrusive.js"></script>
    <script type="text/javascript" src="/admin_mall/content/my97datepicker/WdatePicker.js"></script>
    <link href="/admin_mall/content/css/uploadify.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        //防止chrome缓存jquery.uploadify.js文件，而引起chrome崩溃
        document.write("<script type='text/javascript' "
            + "src='/admin_mall/scripts/jquery.uploadify.js?" + new Date()
            + "'></s" + "cript>");  
    </script>
    <script type="text/javascript">
        $(function () {
            $("#uploadify").uploadify({
                'formData': { 'uid': '@WorkContext.Uid', 'password': '@WorkContext.EncryptPwd' },
                'swf': '/admin_mall/content/flashes/uploadify.swf',
                'uploader': '@WorkContext.MallConfig.UploadServer/malladmin/tool/upload?operation=uploadadvertbody',
                'buttonText': '上传',
                'height': 24,
                'width': 80,
                'fileTypeDesc': 'Image Files',
                'fileTypeExts': '@ViewData["allowImgType"]',
                'fileSizeLimit': '@ViewData["maxImgSize"]',
                'auto': true,
                'multi': false,
                'removeTimeout': 2,
                'onUploadSuccess': function (file, data, response) {
                    if (data == "-1")
                        alert('上传内容不能为空');
                    else if (data == "-2")
                        alert('上传内容的类型不允许');
                    else if (data == "-3")
                        alert('上传内容超过系统允许的最大大小');
                    else {
                        $(".uploadPreview").empty().append("已上传");
                        $("#Body").val(data);
                        $(".upload span[htmlFor='Body']").empty();
                    }
                }
            });

            var typeValue = $("input:radio[name='Type']:checked").val();
            if (typeValue == "0") {
                $(".upload").hide();
                $("#inputBody").show();
                $("#urlTr").show();
            }
            else if (typeValue == "1") {
                $(".upload").show();
                $("#inputBody").hide();
                $("#urlTr").show();
            }
            else if (typeValue == "2") {
                $(".upload").show();
                $("#inputBody").hide();
                $("#urlTr").show();
            }
            else {
                $(".upload").hide();
                $("#inputBody").show();
                $("#urlTr").hide();
            }

            $("input:radio[name='Type']").click(function () {
                typeValue = $("input:radio[name='Type']:checked").val();
                if (typeValue == "0") {
                    $(".upload").hide();
                    $("#inputBody").show();
                    $("#urlTr").show();
                }
                else if (typeValue == "1") {
                    $(".upload").show();
                    $("#inputBody").hide();
                    $("#urlTr").show();
                }
                else if (typeValue == "2") {
                    $(".upload").show();
                    $("#inputBody").hide();
                    $("#urlTr").show();
                }
                else {
                    $(".upload").hide();
                    $("#inputBody").show();
                    $("#urlTr").hide();
                }
            })
        });
    
    </script>
}

@section body{
<h1 class="rightH1">
广告管理 &gt;&gt; 编辑广告
<div class="right">
<a href="@Html.Raw(ViewData["referer"].ToString())" class="menuBT"><img src="/admin_mall/content/images/goback.jpg"/>返回列表</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</h1>

@using (Html.BeginForm())
{
<div class="addTable">
<table width="100%">
      <tr>
    <td width="56px" align="right">标题：</td>
    <td>@Html.TextBoxFor(x => x.Title, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.Title)</td>
    </tr>
    <tr>
    <td align="right">位置：</td>
    <td>@Html.DropDownListFor(x => x.AdPosId, ViewData["advertPositionList"] as List<SelectListItem>)@Html.ValidationMessageFor(x => x.AdPosId)
    </td>
    </tr>
    <tr>
        <td align="right">类型：</td>
        <td>
            <p>
                <label>@Html.RadioButtonFor(x => x.Type, 0, new { @class = "checkbox" }) 文字</label>
                <label>@Html.RadioButtonFor(x => x.Type, 1, new { @class = "checkbox" }) 图片</label>
                <label>@Html.RadioButtonFor(x => x.Type, 2, new { @class = "checkbox" }) Flash</label>
                <label>@Html.RadioButtonFor(x => x.Type, 3, new { @class = "checkbox" }) 代码</label>
                <br />
            </p>
        </td>
    </tr>
   <tr>
    <td align="right">主体：</td>
    <td>
      <div class="upload" style=" display:none;">
        <div class="uploadPreview">
        @if (!string.IsNullOrEmpty(Model.Body))
        {
             @:已上传
        }
        else
        {
             @:未上传
        }
        </div>
        <div class="uploadProgressBar" id="uploadify-queue"></div>
        <div class="uploadBut"><input type="file" name="uploadify" id="uploadify" /></div>
        <div style="position:absolute; top:30px; left:180px;"></div>
      </div>
      <div id="inputBody">@Html.TextAreaFor(x => x.Body, new { cols = "40", rows = "6" })</div>
      @Html.ValidationMessageFor(x => x.Body)
    </td>
    </tr>
    <tr id="urlTr">
    <td align="right">网址：</td>
    <td>@Html.TextBoxFor(x => x.Url, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.Url)</td>
    </tr>
    <tr>
    <td align="right">时间：</td>
    <td>
        @Html.TextBoxFor(x => x.StartTime, new { @class = "input", size = "18", onfocus = "WdatePicker({el:'StartTime'})" })
        至
        @Html.TextBoxFor(x => x.EndTime, new { @class = "input", size = "18", onfocus = "WdatePicker({el:'EndTime'})" })
        @Html.ValidationMessageFor(x => x.StartTime)
        @Html.ValidationMessageFor(x => x.EndTime)
    
    </td>
    </tr>
        <tr>
    <td align="right">扩展1：</td>
    <td>@Html.TextBoxFor(x => x.ExtField1, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.ExtField1)</td>
    </tr>
        <tr>
    <td align="right">扩展2：</td>
    <td>@Html.TextBoxFor(x => x.ExtField2, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.ExtField2)</td>
    </tr>
        <tr>
    <td align="right">扩展3：</td>
    <td>@Html.TextBoxFor(x => x.ExtField3, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.ExtField3)</td>
    </tr>
        <tr>
    <td align="right">扩展4：</td>
    <td>@Html.TextBoxFor(x => x.ExtField4, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.ExtField4)</td>
    </tr>
        <tr>
    <td align="right">扩展5：</td>
    <td>@Html.TextBoxFor(x => x.ExtField5, new { @class = "input", size = "35" })@Html.ValidationMessageFor(x => x.ExtField5)</td>
    </tr>
    <tr>
    <td align="right">排序：</td>
    <td>@Html.TextBoxFor(x => x.DisplayOrder, new { @class = "input", size = "10" })@Html.ValidationMessageFor(x => x.DisplayOrder)</td>
    </tr>
    <tr>
        <td align="right">状态：</td>
        <td>
            <p>
                <label>@Html.RadioButtonFor(x => x.State, 0, new { @class = "checkbox" }) 隐藏</label>
                <label>@Html.RadioButtonFor(x => x.State, 1, new { @class = "checkbox" }) 展示</label>
                <br />
            </p>
        </td>
    </tr>
    <tr>
    <td align="right">&nbsp;</td>
    <td>
    <a href="" class="addBt" id="sumbitBut" ><img src="/admin_mall/content/images/submit.jpg" /></a>
            <script type="text/javascript">
                $(function () {
                    $("#sumbitBut").click(function () {
                        $("form:first").submit();
                        return false;
                    })
                });
        </script>
    </td>
    </tr>
      <tr>
    <td align="right">&nbsp;</td>
    <td>&nbsp;</td>
    </tr>
</table>
</div>
}
}